// @ts-ignore
import { request } from '@umijs/max';

// 生成对话
export async function generateDialog(body: any) {
  return request<API.ReqResult>(`/api/dialog/generate`, {
    method: 'POST',
    data: body,
  });
}

// 获取对话版本列表
export async function dialogVersions(params: any) {
  return request<{
    code: number;
    msg: string;
    data: API.Versions;
  }>(`/api/dialog/versions`, {
    method: 'GET',
    params,
  });
}

// 获取AI协作记录（旧）
export async function getDialogLogs(params: any) {
  return request<{
    code: number;
    msg: string;
    data: API.AILogs;
  }>(`/api/dialog/versions/log`, {
    method: 'GET',
    params,
  });
}

// 获取AI协作记录（新）
export async function getDialogLogs_V2(params: any) {
  return request<API.ReqResult>(`/v2/api/dialog/versions/log`, {
    method: 'GET',
    params,
  });
}
// 提炼要点
export async function extractKeyPoints(body: any) {
  return request<API.ReqResult>(`/api/dialog/extract_key_points`, {
    method: 'POST',
    data: body,
  });
}

// 结构化推理
export async function structuringWrite(body: any) {
  return request<API.ReqResult>(`/api/dialog/structuring_write`, {
    method: 'POST',
    data: body,
  });
}

// 查询单个会话
export async function getSessionDetail(sessionId: any) {
  return request<API.ReqResult>(`/api/writing_session/${sessionId}`, {
    method: 'GET',
  });
}

// 停止生成
export async function stopSession(sessionId: any) {
  return request<API.ReqResult>(`/api/writing_session/${sessionId}`, {
    method: 'PUT',
    data: { stop_generation: true },
  });
}

// 更新会话
export async function updateSession(params: any) {
  return request<API.ReqResult>(`/api/writing_session/${params.sessionId}`, {
    method: 'PUT',
    data: { last_document_id: params.last_document_id },
  });
}
